﻿
//DemoControl, the demo control.
LightScript.using("LightScript.Core", "LightScript.Dom", "LightScript.UI.Controls.Control", "LightScript.Function", function()
{
    LightScript.Core.createNamespace("LightScript.UI.Controls");
    var thisClass = LightScript.Core.createClass("LightScript.UI.Controls.DemoControl: LightScript.UI.Controls.Control",
    function(id)
    {
        LightScript.Core.base(this, LightScript.UI.Controls.Control, [id]);

        var e = document.createElement("div");
        e.id = id;
        LightScript.EventList.add(this.getObjectId(e.id), "click", onClick);
        e.onclick = LightScript.EventList.get(this.getObjectId(e.id), "click");
        e.innerHTML = "Demo Control";
        this._element = e;
        LightScript.EventList.add(this.getObjectId(e.id), "click", onClick1, true);
        LightScript.EventList.add(this.getObjectId(e.id), "click", LightScript.Function.createDelegate(this.onClick3, this, [], true), true);
    });

    //# Private Members

    //# Constructions

    //# Public Members

    //# Private Methods

    //# Public Methods
    thisClass.prototype.render = function(containerId)
    {
        LightScript.get(containerId).appendChild(this._element);

        LightScript.EventList.remove(this.getObjectId(this._element.id), "click", onClick);
        //LightScript.EventList.remove(this.getObjectId(this._element.id), "click");
        //LightScript.EventList.add(this.getObjectId(this._element.id), "click", onClick1, true);
    }

    //# Private Event Handlers
    function onClick(sender, args)
    {
        alert([0, sender, args]);
    }

    function onClick1(sender, args)
    {
        alert([1, sender, args]);
    }

    thisClass.prototype.onClick3 = function(sender, args)
    {
        alert([this.id, sender, args]);
    }

    //# Public Event Handlers

    //# Shortcuts
});
